package com.camunda.workflow.domain.entity;

import com.camunda.workflow.common.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import static com.camunda.workflow.common.consts.CommonCst.KEY_GEN;

/**
 * 租户
 */
@ApiModel
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@Accessors(chain = true)
@Table(value = "sys_tenant_user_role")
public class SysTenantUserRole extends BaseEntity {
    @Id(keyType = KeyType.Generator, value = KeyGenerators.ulid)
    private String id;
    @JsonSerialize(using = ToStringSerializer.class)
    private String tenantId;
    @JsonSerialize(using = ToStringSerializer.class)
    private String userId;
    @JsonSerialize(using = ToStringSerializer.class)
    private String roleId;

    @RelationOneToOne(selfField = "tenant_id", targetField = "id", targetTable = "sys_tenant")
    protected SysTenant tenant;
    @RelationOneToOne(selfField = "user_id", targetField = "id", targetTable = "sys_user")
    protected SysUser user;
    @RelationOneToOne(selfField = "role_id", targetField = "id", targetTable = "sys_role")
    protected SysRole role;
}
